package com.kcloud.jpa;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.kcloud.jpa.repository.Repository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * KCLOUD JPA 配置对象
 * @author: songhuiqing
 */
@Configuration
public class KcloudJPaConfiguration {

    /**
     * 全局翻页设置
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * mp参数设置
     * @return
     */
    @Bean
    @Primary
    public MybatisPlusProperties mybatisPlusProperties() {
        MybatisPlusProperties properties = new MybatisPlusProperties();
        properties.getGlobalConfig().setSuperMapperClass(Repository.class);
        return properties;
    }
}
